<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>运输计划变更记录</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 
		首页 <span class="c-gray en">&gt;</span> 
		业务管理 <span class="c-gray en">&gt;</span> 
		运输计划变更记录 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c"> 申请日期范围：
		<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" class="input-text Wdate" style="width:120px;">
		<input type="text" class="input-text" style="width:250px" placeholder="输入申请人名称" id="userName" name="">
		分公司:
		<span class="select-box inline">
		<select class="select" id="comId" name="comId">
			<option value="">请选择分公司</option>
		</select>
		</span>
		票务室:
		<span class="select-box inline">
		<select class="select" id="toId" name="toId">
			<option value="">请选择票务室</option>
		</select>
		</span>
		<button type="submit" class="btn btn-success" id=""  onClick="queryUserName()" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <!-- <a href="javascript:;" onclick="admin_add('添加管理员','admin-add.html','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 应急申请</a>--></span>  <span  id="userLength" class="r"> </div>
	<!-- <table class="table table-border table-bordered table-bg"> -->
	<!-- <table id="list" class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"  ><input type="checkbox" name="emergencyApplicationId" value=""></th>
				<th width="150">ID</th>
				<th width="150" align="center">申请人</th>
				<th width="150" align="center">角色</th>
				<th width="150" align="center">申请时间</th>
				<th width="150" align="center">取胆时间</th>
				<th width="150" align="center">数量</th>
				<th width="100" align="center">物流人员</th>
				<th width="100" align="center">清分人员</th>
				<th width="100" align="center">详情描述</th>
			</tr>
		</thead>
                            
		<tbody id="divListId">
			

		</tbody>
	</table> -->
	</div>
	<div style="padding: 20px;">
		<table id="divListId" class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th id="thid"><input type="checkbox"  style="float:left;"  name="emergencyApplicationId"></th>
					<th >申请人</th>
					<th >所属公司</th>
					<th >所属票务室</th>
					<th >角色</th>
					<th >申请时间</th>
					<th >取胆时间</th>
					<th >数量</th>
					<th >物流人员</th>
					<th >清分人员</th>
					<th >详情描述</th>
				</tr>
			</thead>
		</table>
	</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript">


$(document).ready(function(){
		
var comId;
var toId;
	var username = window.localStorage.getItem("user_name");
	console.log(username);
	var myArray;

	$.ajax({
		type: 'get',
		url: report_service+'/getAllCompany',
		 beforeSend: function (request) {
						request.setRequestHeader("Authorization", "Bearer " + getToken());
					}, 
		dataType: 'json',
		async: false,
		success: function(data){
			var list =  eval('(' + data.list + ')');
			for(var i = 0;i<list.length;i++){
				$("#comId").append("<option value='"+list[i].companyid+"'>"+list[i].companyname+"</option>");				
			}
		},
		error: function(data){
			console.log(data.msg);
		}
	});
	
	$.ajax({
		type: 'get',
		url: report_service+'/getUserByname',
		data:{
			"username": username
		},
		async: false,
		 beforeSend: function (request) {
						request.setRequestHeader("Authorization", "Bearer " + getToken());
					}, 
		dataType: 'json',
		success: function(data){
			console.log(data.list);
			var list =  eval('(' + data.list + ')');
			console.log(list[0].officeId+"--"+list[0].companyId);
			if(list[0].officeId.indexOf("1")==0){
				console.log("票务室人员登录");
				$("#comId").val(list[0].companyId);
				comId = list[0].companyId;
				/* var comLength = $("#comId option").length;
				console.log($("#comId option[index='"+i+"']").val); */
				
				$.ajax({
					type: 'get',
					url: report_service+'/getTicktOfficeByCom',
					 beforeSend: function (request) {
									request.setRequestHeader("Authorization", "Bearer " + getToken());
								}, 
					data:{
						"comId":comId
					},
					cache:false,    
					dataType:'json',
					async: false,
					success: function(data){
						//var list = data.list;
						var list =  eval('(' + data.list + ')');
						for(var i=0;i<list.length;i++){
							var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
							$("#toId").append(option);
						}
					},
					error:function(){
						alert("请求失败");
					}
				});
				$("#toId").val(list[0].officeId);
				toId = list[0].officeId;
				$("#comId").attr("disabled","disabled");
				$("#toId").attr("disabled","disabled");
			}
			if(list[0].officeId.indexOf("1")==-1 && list[0].companyId.indexOf("1")==0){
				console.log("分公司人员登录");
				$("#comId").val(list[0].companyId);
				comId = list[0].companyId;
				$.ajax({
					type: 'get',
					url: report_service+'/getTicktOfficeByCom',
					 beforeSend: function (request) {
									request.setRequestHeader("Authorization", "Bearer " + getToken());
								}, 
					data:{
						"comId":comId
					},
					cache:false,    
					dataType:'json',
					async: false,
					success: function(data){
						//var list = data.list;
						var list =  eval('(' + data.list + ')');
						for(var i=0;i<list.length;i++){
							var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
							$("#toId").append(option);
						}
					},
					error:function(){
						alert("请求失败");
					}
				});
				$("#comId").attr("disabled","disabled");
			}
		},
		error: function(data){
			console.log(data.msg);
		}
	});
	
		queryUserName();
});





$("#comId").change(function(){
	$("#toId").empty();
	var comId = $(this).val();
	var targetUrl = report_service+'/getTicktOfficeByCom';
	if(comId == ''){
		//$("#toId").fadeOut("slow");
		return;
	}
	$.ajax({
		type: 'get',
		url: targetUrl,
		 beforeSend: function (request) {
						request.setRequestHeader("Authorization", "Bearer " + getToken());
					}, 
		data:{
			"comId":comId
		},
		cache:false,    
		dataType:'json',  
		success: function(data){
			//var list = data.list;
			var list =  eval('(' + data.list + ')');
			var option2 = '<option value="">请选择票务室</option>';
			$("#toId").append(option2);
			for(var i=0;i<list.length;i++){
				var option = '<option value="'+list[i].toiid+'">'+list[i].toiname+'</option>';
				$("#toId").append(option);
			}
		},
		error:function(){
			alert("请求失败");
		}
	});
});




function queryUserName(){
	
	
			var datemin=document.getElementById("datemin").value;
			var datemax=document.getElementById("datemax").value;
			var userName=document.getElementById("userName").value;
			var comId =  $("#comId").val();
			var officeId =  $("#toId").val();

					$.ajax(abnormalreport_service+'EmergencyApplication/getEmergencyApplication', {
					data: {
					datemin:datemin,
					datemax:datemax,
					userName:userName,
					comId:comId,
					officeId:officeId
					},
					 beforeSend: function (request) {
											request.setRequestHeader("Authorization", "Bearer " + getToken());
										}, 
					dataType: 'json',			
					type: 'post',
					//timeout:3000,//超时时间设置为10秒；
					success: function(data) {
						$('#divListId').DataTable( {
							   data: data.list,
							   //stateSave: true,
							   "lengthMenu":[10, 50, 100],
							   "pageLength": 100,
							   //使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
							   //data 这里是固定不变的，name，position，salary，office 为你数据里对应的属性
							   destroy:true,
							   columns: [
								   { data: 'id' },
								   { data: 'userId'},
								   { data: 'companyName'},
								   { data: 'officeName'},
								   { data: 'CSId' },
								   { data: 'createTime'},
								   { data: 'getTime'},
								   { data: 'CNum' },
								   { data: 'LCId'},
								   { data: 'BCId'},
								   { data: 'content' },
							   ],

							  columnDefs: [
								 // +'<td><a href="javascript:;" onclick="admin_add(\''+list[i].id+'\')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 审核</a></td>'
								{
									"orderable": false,
								    "targets": 0
								},  {
								     "targets": 0,//
								     "data": null,
								     render: function(data, type, row, meta) {
										
								  		   return '<input type="checkbox" value='+data+' style="float:left;"  name="emergencyApplicationId">'
					
								     }
								  } 
									]
						   } );
						    document.getElementById("thid").setAttribute("class","");
					},
					error: function(e) {
						//alert("错误456");
					}
				});

}




function datadel (){

				var chk_value =[];//定义一个数组    
				var ids = "";
				$('input[name="emergencyApplicationId"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
				chk_value.push($(this).val());//将选中的值添加到数组chk_value中   
					ids=ids+$(this).val()+","
					
				});
				
				$.ajax(abnormalreport_service+'EmergencyApplication/delEmergencyApplicationByIds',{
					data:{
						"ids":ids
					},
					  beforeSend: function (request) {
											request.setRequestHeader("Authorization", "Bearer " + getToken());
										},  
					dataType: 'json',
					type: 'post',
					//timeout:3000,//超时时间设置为10秒；
					success: function(data) {
						window.location.reload()//刷新当前页面.
					},
					error: function(e) {
					
					}
				});
			
			
}

</script>
</body>
</html>